package com.ruoyi.appService.mentalTestResult.careeranchorResult.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.appService.mentalTestResult.huolandResult.domain.ZTestHuolandTestresult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appService.mentalTestResult.careeranchorResult.domain.ZTestCareeranchorTestresult;
import com.ruoyi.appService.mentalTestResult.careeranchorResult.service.IZTestCareeranchorTestresultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职业锚心理测试结果Controller
 * 
 * @author anjiao
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/mentalTest/careeranchorTestResult")
public class ZTestCareeranchorTestresultController extends BaseController
{
    @Autowired
    private IZTestCareeranchorTestresultService zTestCareeranchorTestresultService;

    /**
     * 查询职业锚心理测试结果列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchorTestResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZTestCareeranchorTestresult zTestCareeranchorTestresult)
    {
        startPage();
        List<ZTestCareeranchorTestresult> list = zTestCareeranchorTestresultService.selectZTestCareeranchorTestresultList(zTestCareeranchorTestresult);
        return getDataTable(list);
    }

    /**
     * 导出职业锚心理测试结果列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchorTestResult:export')")
    @Log(title = "职业锚心理测试结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZTestCareeranchorTestresult zTestCareeranchorTestresult)
    {
        List<ZTestCareeranchorTestresult> list = zTestCareeranchorTestresultService.selectZTestCareeranchorTestresultList(zTestCareeranchorTestresult);
        ExcelUtil<ZTestCareeranchorTestresult> util = new ExcelUtil<ZTestCareeranchorTestresult>(ZTestCareeranchorTestresult.class);
        util.exportExcel(response, list, "职业锚心理测试结果数据");
    }

    /**
     * 获取职业锚心理测试结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchorTestResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zTestCareeranchorTestresultService.selectZTestCareeranchorTestresultById(id));
    }

    /**
     * 新增职业锚心理测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchorTestResult:add')")
    @Log(title = "职业锚心理测试结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZTestCareeranchorTestresult zTestCareeranchorTestresult)
    {
        return toAjax(zTestCareeranchorTestresultService.insertZTestCareeranchorTestresult(zTestCareeranchorTestresult));
    }

    /**
     * 修改职业锚心理测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchorTestResult:edit')")
    @Log(title = "职业锚心理测试结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZTestCareeranchorTestresult zTestCareeranchorTestresult)
    {
        return toAjax(zTestCareeranchorTestresultService.updateZTestCareeranchorTestresult(zTestCareeranchorTestresult));
    }

    /**
     * 删除职业锚心理测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchorTestResult:remove')")
    @Log(title = "职业锚心理测试结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zTestCareeranchorTestresultService.deleteZTestCareeranchorTestresultByIds(ids));
    }


    // 给小程序端提供的新增或修改测试结果
    @PostMapping("addOrUpdate")
    public AjaxResult addOrupdateTestResult(@RequestBody ZTestCareeranchorTestresult zTestCareeranchorTestresult, HttpServletRequest request)
    {
        zTestCareeranchorTestresultService.addOrupdateTestResult(zTestCareeranchorTestresult,request);
        return AjaxResult.success();
    }

    //    查询测试结果根据用户id
    @PostMapping ("selectTestResult")
    public AjaxResult selectTestResult( HttpServletRequest request)
    {
        return  zTestCareeranchorTestresultService.selectTestResult(request);
    }

}
